using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NhaThuocOnline.Entities.Mapping
{
    public class HoaDonBanHangChiTietMap : EntityTypeConfiguration<HoaDonBanHangChiTiet>
    {
        public HoaDonBanHangChiTietMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.DonGiaBan)
                .HasMaxLength(50);

            this.Property(t => t.SoLuongXuat)
                .HasMaxLength(50);

            this.Property(t => t.CachUong)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("HoaDonBanHangChiTiet");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.BietDuocId).HasColumnName("BietDuocId");
            this.Property(t => t.HoaDonBanHangId).HasColumnName("HoaDonBanHangId");
            this.Property(t => t.DonGiaBan).HasColumnName("DonGiaBan");
            this.Property(t => t.SoLuongXuat).HasColumnName("SoLuongXuat");
            this.Property(t => t.SoLanMoiNgay).HasColumnName("SoLanMoiNgay");
            this.Property(t => t.SoVienMoiLan).HasColumnName("SoVienMoiLan");
            this.Property(t => t.CachUong).HasColumnName("CachUong");

            // Relationships
            this.HasOptional(t => t.BietDuoc)
                .WithMany(t => t.HoaDonBanHangChiTiets)
                .HasForeignKey(d => d.BietDuocId);
            this.HasOptional(t => t.HoaDonBanHang)
                .WithMany(t => t.HoaDonBanHangChiTiets)
                .HasForeignKey(d => d.HoaDonBanHangId);

        }
    }
}
